GM.Name 	= "Skeleton Gamemode"
GM.Author 	= "N/A"
GM.Email 	= "N/A"
GM.Website 	= "N/A"

GAME = {};

GAME.FolderName = "Skeleton";
GAME.Debug = true;
DeriveGamemode("sandbox");

function GM:Initialize()

	self.BaseClass.Initialize( self )
	
end

--Thanks to the PAC team for this list.
GAME.BoneList = {

	["pelvis"			] = "ValveBiped.Bip01_Pelvis"		,
	["stomach"			] = "ValveBiped.Bip01_Spine"		,
	["lower back"		] = "ValveBiped.Bip01_Spine1"		,
	["chest"			] = "ValveBiped.Bip01_Spine2"		,
	["upper back"		] = "ValveBiped.Bip01_Spine4"		,
	["neck"				] = "ValveBiped.Bip01_Neck1"		,
	["head"				] = "ValveBiped.Bip01_Head1"		,
	["right clavicle"	] = "ValveBiped.Bip01_R_Clavicle"	,
	["right upper arm"	] = "ValveBiped.Bip01_R_UpperArm"	,
	["right forearm"	] = "ValveBiped.Bip01_R_Forearm"	,
	["right hand"		] = "ValveBiped.Bip01_R_Hand"		,
	["left clavicle"	] = "ValveBiped.Bip01_L_Clavicle"	,
	["left upper arm"	] = "ValveBiped.Bip01_L_UpperArm"	,
	["left forearm"		] = "ValveBiped.Bip01_L_Forearm"	,
	["left hand"		] = "ValveBiped.Bip01_L_Hand"		,
	["right thigh"		] = "ValveBiped.Bip01_R_Thigh"		,
	["right calf"		] = "ValveBiped.Bip01_R_Calf"		,
	["right foot"		] = "ValveBiped.Bip01_R_Foot"		,
	["right toe"		] = "ValveBiped.Bip01_R_Toe0"		,
	["left thigh"		] = "ValveBiped.Bip01_L_Thigh"		,
	["left calf"		] = "ValveBiped.Bip01_L_Calf"		,
	["left foot"		] = "ValveBiped.Bip01_L_Foot"		,
	["left toe"			] = "ValveBiped.Bip01_L_Toe0"	
	
};


--Converts a bone's name from it's shortened version to the full skeleton bone's name.
function GAME.BoneToFull( bone )

	return GAME.BoneList[ bone ];
	
end

--Does the opposite of the above.
function GAME.BoneToShort( bone )

	for k, v in pairs( GAME.BoneList ) do
	
		if v == string.lower(bone) then
		
			return k;
			
		end
		
	end
	
end

GAME.OffSets = { //I didnt steal this from _Undefined, but thanks for the method <3
	 [1] = function(Pos, Ang)//["weapon_pistol"]
		Pos = Pos + Ang:Forward()*5 - Ang:Up()*3.25
		Ang:RotateAroundAxis(Ang:Up(), 180)
		Ang:RotateAroundAxis(Ang:Forward(), -90)
		return Pos, Ang
	end,
	[2] = function(Pos, Ang)//["weapon_357"]
		Pos = Pos + Ang:Forward() - Ang:Up()*3.25 - Ang:Right()*3
		Ang:RotateAroundAxis(Ang:Forward(), 90)
		return Pos, Ang
	end,
	[3] = function(Pos, Ang)//["gmod_tool"]
		Pos = Pos + Ang:Forward() - Ang:Up()*3.25 - Ang:Right()*3
		Ang:RotateAroundAxis(Ang:Forward(), 90)
		return Pos, Ang
	end,
	[4] = function(Pos, Ang)//["weapon_ar2"]
		Ang:RotateAroundAxis(Ang:Up(), 180)
		Ang:RotateAroundAxis(Ang:Right(), 20)
		Pos = Pos + Ang:Forward()*-8 + Ang:Right()*-4 + Ang:Up()*-2
		return Pos, Ang
	end, 
	[5] = function(Pos, Ang)//["weapon_smg1"]
		Ang:RotateAroundAxis(Ang:Right(), -30)
		Pos = Pos + Ang:Right()*5 + Ang:Forward()*3
		return Pos, Ang
	end,
	[6] = function(Pos, Ang)//["weapon_shotgun"]
		Ang:RotateAroundAxis(Ang:Up(), 180)
		Ang:RotateAroundAxis(Ang:Right(), 20)
		Pos = Pos + Ang:Right()*-3.75 + Ang:Forward()*-5 + Ang:Up()*-1
		return Pos, Ang
	end,
	[7] = function(Pos, Ang)//["weapon_crossbow"]
		Ang:RotateAroundAxis(Ang:Right(), -20)
		Ang:RotateAroundAxis(Ang:Forward(), 90)
		Pos = Pos + Ang:Right() + Ang:Forward()*-10
		return Pos, Ang
	end,
	[8] = function(Pos, Ang)//["weapon_physgun"]
		Ang:RotateAroundAxis(Ang:Right(), -20)
		Ang:RotateAroundAxis(Ang:Forward(), 90)
		Pos = Pos + Ang:Right() + Ang:Forward()*-10 + Ang:Up()*4
		return Pos, Ang
	end,
	[9] = function(Pos, Ang)//["weapon_physcannon"]
		Ang:RotateAroundAxis(Ang:Right(), -20)
		Ang:RotateAroundAxis(Ang:Forward(), 90)
		Pos = Pos + Ang:Right() + Ang:Forward()*-10 + Ang:Up()*4
		return Pos, Ang
	end,
	[10] = function(Pos, Ang)//["weapon_rpg"]
		Ang:RotateAroundAxis(Ang:Up(), 180)
		Ang:RotateAroundAxis(Ang:Right(), 180)
		Ang:RotateAroundAxis(Ang:Forward(), 105)
		Pos = Pos + Ang:Right()*-.5 + Ang:Forward()*10 - Ang:Up()*4
		return Pos, Ang
	end,
	[11] = function(Pos, Ang)//["weapon_crowbar"]
		Ang:RotateAroundAxis(Ang:Up(), 180)
		Ang:RotateAroundAxis(Ang:Right(), -30)
		Ang:RotateAroundAxis(Ang:Forward(), -30)
		Pos = Pos + Ang:Right()*-4 + Ang:Forward() - Ang:Up()
		return Pos, Ang
	end
};

GAME.ItemList = {};
function ItemsRegister()

	for _, itemfile in pairs( file.FindInLua(GAME.FolderName .. "/gamemode/items/*.lua") ) do
	
		ITEM = {};
		
		if (SERVER) then
		
			AddCSLuaFile(GAME.FolderName .. "/gamemode/items/" .. itemfile);
			
		end
		
		include(GAME.FolderName .. "/gamemode/items/" .. itemfile);
		
		table.insert(GAME.ItemList, ITEM);
		util.PrecacheModel(ITEM.Model);	
		
		ITEM = nil;
		
	end;
	
	print("Finished Loading Items!");
	
end
ItemsRegister();